//
//  UIBarButtonItem+Init.m
//  WeiBo
//
//  Created by ChenJunWen on 2017/11/29.
//  Copyright © 2017年 CJW. All rights reserved.
//

#import "UIBarButtonItem+Init.h"

@implementation UIBarButtonItem (Init)

+ (instancetype)setTitle:(NSString *)title fontSize:(CGFloat)fontSize target:(id)target action:(SEL)action isBack:(BOOL)isBack {
    UIButton *btn = [UIButton jw_textButton:title fontSize:fontSize normalColor:[UIColor darkGrayColor] highlightedColor:[UIColor orangeColor]];
    if (isBack) {
        NSString *imageName = @"navigationbar_back_withtext";
        
        [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
        [btn setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted", imageName]] forState:UIControlStateHighlighted];
        [btn sizeToFit];
    }
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[self alloc] initWithCustomView:btn];
}

@end
